﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace Gmantis.Controls
{
    public abstract class ScrollViewerCornerRadiusBase : FrameworkElement, INotifyPropertyChanged
    {
        // Fields
        public static readonly DependencyProperty CornerRadiusProperty;
        public static readonly DependencyProperty HorizontalScrollBarVisibilityProperty;
        public static readonly DependencyProperty VerticalScrollBarVisibilityProperty;

        // Events
        public event PropertyChangedEventHandler PropertyChanged;

        // Methods
        static ScrollViewerCornerRadiusBase()
        {
            CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ScrollViewerCornerRadiusBase), new PropertyMetadata(new CornerRadius(), (d, a) => (d as ScrollViewerCornerRadiusBase).UpdateOutput()));
            VerticalScrollBarVisibilityProperty = DependencyProperty.Register("VerticalScrollBarVisibility", typeof(Visibility), typeof(ScrollViewerCornerRadiusBase), new PropertyMetadata(Visibility.Collapsed, (d, a) => (d as ScrollViewerCornerRadiusBase).UpdateOutput()));
            HorizontalScrollBarVisibilityProperty = DependencyProperty.Register("HorizontalScrollBarVisibility", typeof(Visibility), typeof(ScrollViewerCornerRadiusBase), new PropertyMetadata(Visibility.Collapsed, (d, a) => (d as ScrollViewerCornerRadiusBase).UpdateOutput()));
        }

        public ScrollViewerCornerRadiusBase()
        {
            base.Width = base.Height = 0.0;
        }

        protected void RaisePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        protected abstract void UpdateOutput();

        // Properties
        public CornerRadius CornerRadius
        {
            get
            {
                return (CornerRadius)base.GetValue(CornerRadiusProperty);
            }
            set
            {
                base.SetValue(CornerRadiusProperty, value);
            }
        }

        public Visibility HorizontalScrollBarVisibility
        {
            get
            {
                return (Visibility)base.GetValue(HorizontalScrollBarVisibilityProperty);
            }
            set
            {
                base.SetValue(HorizontalScrollBarVisibilityProperty, value);
            }
        }

        public Visibility VerticalScrollBarVisibility
        {
            get
            {
                return (Visibility)base.GetValue(VerticalScrollBarVisibilityProperty);
            }
            set
            {
                base.SetValue(VerticalScrollBarVisibilityProperty, value);
            }
        }
    }
}
